package com.example.administrator.printoutindemo.mvp.ui.activity;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.dds.soap.SoapListener;
import com.dds.soap.SoapParams;
import com.dds.soap.SoapUtil;
import com.example.administrator.printoutindemo.R;
import com.example.administrator.printoutindemo.di.component.DaggerSaoMiaoChaKanXiangQingComponent;
import com.example.administrator.printoutindemo.di.module.SaoMiaoChaKanXiangQingModule;
import com.example.administrator.printoutindemo.mvp.contract.SaoMiaoChaKanXiangQingContract;
import com.example.administrator.printoutindemo.mvp.presenter.SaoMiaoChaKanXiangQingPresenter;
import com.example.administrator.printoutindemo.mvp.ui.adapter.SaoMiaoChaKanXiangQingAdapter;
import com.example.administrator.printoutindemo.mvp.ui.adapter.SaoMiaoChaKanXiangQingAdapter_FirstCheckList;
import com.example.administrator.printoutindemo.mvp.ui.adapter.SaoMiaoChaKanXiangQingAdapter_InStoreList;
import com.example.administrator.printoutindemo.mvp.ui.adapter.SaoMiaoChaKanXiangQingAdapter_InspectionList;
import com.example.administrator.printoutindemo.mvp.ui.adapter.SaoMiaoChaKanXiangQingAdapter_ReturnStoreList;
import com.example.administrator.printoutindemo.mvp.ui.entity.GetMaterialDetailInfo;
import com.example.administrator.printoutindemo.mvp.ui.entity.SaoMiaoChaKanXiangQing;
import com.example.administrator.printoutindemo.utils.GlideUtil;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.BaseConstants;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.LogUtils;
import com.xiaoxing.zhinenghuacangku.mvp.ui.activity.ScanQRCodeActivity;

import org.jetbrains.annotations.NotNull;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.jess.arms.utils.CProgressDialogUtils;
import me.jessyan.armscomponent.commonres.utils.ToolbarUtils;
import me.jessyan.armscomponent.commonres.view.RecycleViewDivider;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import pub.devrel.easypermissions.EasyPermissions;

import static com.jess.arms.base.BaseConstants.SCAN_REQUEST_CODE;
import static com.jess.arms.utils.Preconditions.checkNotNull;


@Route(path = RouterHub.ACTIVITY_SAO_MIAO_CHA_KAN_XIANG_QING)
public class SaoMiaoChaKanXiangQingActivity extends BaseActivity<SaoMiaoChaKanXiangQingPresenter> implements SaoMiaoChaKanXiangQingContract.View, EasyPermissions.PermissionCallbacks {
    @BindView(R.id.btnRight)
    ImageView mBtnRight;
    @BindView(R.id.tv_xiang_mu)
    TextView tvXiangMu;
    @BindView(R.id.tv_wu_liao_ming_cheng)
    TextView tvWuLiaoMingCheng;
    @BindView(R.id.tv_he_tong_qian_ding_qi_qi)
    TextView tvHeTongQianDingQiQi;
    @BindView(R.id.tv_pei_song_ji_hua_ri_qi)
    TextView tvPeiSongJiHuaRiQi;
    @BindView(R.id.tv_dao_huo_shi_jian)
    TextView tvDaoHuoShiJian;
    @BindView(R.id.tv_ji_hua_shu_liang)
    TextView tvJiHuaShuLiang;
    @BindView(R.id.tv_ben_ci_dao_huo_shu_liang)
    TextView tvBenCiDaoHuoShuLiang;
    @BindView(R.id.tv_ku_cun_shu_liang)
    TextView tvKuCunShuLiang;
    @BindView(R.id.tv_gong_ying_shang)
    TextView tvGongYingShang;
    @BindView(R.id.tv_gong_ying_shang_lian_xi_ren)
    TextView tvGongYingShangLianXiRen;
    @BindView(R.id.tv_gong_ying_shang_lian_xi_dian_hua)
    TextView tvGongYingShangLianXiDianHua;
    @BindView(R.id.tv_bei_zhu)
    TextView tvBeiZhu;
    @BindView(R.id.tv_hui_shou_bao_fei_zhuang_tai)
    TextView tvHuiShouBaoFeiZhuangTai;
    @BindView(R.id.tv_hui_shou_bao_fei_shi_jian)
    TextView tvHuiShouBaoFeiShiJian;
    @BindView(R.id.tv_hui_shou_bao_fei_shu_liang)
    TextView tvHuiShouBaoFeiShuLiang;
    @BindView(R.id.tv_hui_shou_bao_fei_xiang_mu)
    TextView tvHuiShouBaoFeiXiangMu;
    @BindView(R.id.tv_hui_shou_bao_fei_cang_ku)
    TextView tvHuiShouBaoFeiCangKu;
    @BindView(R.id.tv_chu_ku_ji_lu)
    TextView tvChuKuJiLu;
    @BindView(R.id.tv_cang_wei_wu_liao_shu_liang)
    TextView tvCangWeiWuLiaoShuLiang;
    @BindView(R.id.img_wu_liao)
    ImageView imgWuLiao;
    @BindView(R.id.tv_dan_wei)
    TextView mTvDanWei;
    List<GetMaterialDetailInfo.OutStoreListBean> mOutStoreListBeans = new ArrayList<>();
    List<GetMaterialDetailInfo.ReturnStoreListBean> mReturnStoreListBeans = new ArrayList<>();
    List<GetMaterialDetailInfo.InStoreListBean> mInStoreListBeans = new ArrayList<>();
    List<GetMaterialDetailInfo.InspectionListBean> mInspectionListBeans = new ArrayList<>();
    List<GetMaterialDetailInfo.FirstCheckListBean> mFirstCheckListBeans = new ArrayList<>();
    @BindView(R.id.et_chu_ku_shu_liang)
    EditText etChuKuShuLiang;
    @BindView(R.id.btn_chu_ku)
    Button btnChuKu;
    @BindView(R.id.et_biao_shi_xin_xi)
    EditText etBiaoShiXinXi;
    private String mid;
    private String mType = "";

    private String[] permissions = {Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
    private SaoMiaoChaKanXiangQingAdapter mSaoMiaoChaKanXiangQingAdapter;
    private SaoMiaoChaKanXiangQingAdapter_ReturnStoreList mSaoMiaoChaKanXiangQingAdapter_returnStoreList;
    private SaoMiaoChaKanXiangQingAdapter_InStoreList mSaoMiaoChaKanXiangQingAdapter_inStoreList;
    private SaoMiaoChaKanXiangQingAdapter_InspectionList mSaoMiaoChaKanXiangQingAdapter_inspectionList;
    private SaoMiaoChaKanXiangQingAdapter_FirstCheckList mSaoMiaoChaKanXiangQingAdapter_firstCheckList;
    private View.OnClickListener mRightListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (getPermission()) {
                LogUtils.debugEInfo("toScanQRCodeActivity=" + mid);

                tvWuLiaoMingCheng.setText("");
                mTvDanWei.setText("");
                tvCangWeiWuLiaoShuLiang.setText("");
                tvKuCunShuLiang.setText("");
                mOutStoreListBeans.clear();
                mSaoMiaoChaKanXiangQingAdapter.notifyDataSetChanged();
                mReturnStoreListBeans.clear();
                mSaoMiaoChaKanXiangQingAdapter_returnStoreList.notifyDataSetChanged();
                mInStoreListBeans.clear();
                mSaoMiaoChaKanXiangQingAdapter_inStoreList.notifyDataSetChanged();
                mInspectionListBeans.clear();
                mSaoMiaoChaKanXiangQingAdapter_inspectionList.notifyDataSetChanged();
                mFirstCheckListBeans.clear();
                mSaoMiaoChaKanXiangQingAdapter_firstCheckList.notifyDataSetChanged();

                toScanQRCodeActivity();


            }
        }
    };
    private RecyclerView mRecyclerView;
    private RecyclerView mRecyclerViewReturnStoreList;
    private RecyclerView mRecyclerViewInStoreList;
    private RecyclerView mRecyclerViewInspectionList;
    private RecyclerView mRecyclerViewFirstCheckList;

    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {

        ArmsUtils.makeText(this, "相关权限获取成功");
    }

    @Override
    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
        ArmsUtils.makeText(this, "请同意相关权限，否则功能无法使用");

    }

    private boolean getPermission() {
        if (EasyPermissions.hasPermissions(this, permissions)) {
            return true;
        } else {
            EasyPermissions.requestPermissions(this, "需要获取您的照相使用权限", 103, permissions);
            return false;
        }

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        LogUtils.debugEInfo("onActivityResult=" + mid);
        if (resultCode == 101) {
            Bundle extras = data.getExtras();
            if (extras != null) {
                mid = "";
                mid = extras.getString("scan_result");
                LogUtils.debugEInfo("mid=" + mid);
                getScanData(mid);
            }

        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
        if (requestCode == 103) {
            toScanQRCodeActivity();
        }
    }

    private void toScanQRCodeActivity() {
        Intent newIntent = new Intent(SaoMiaoChaKanXiangQingActivity.this, ScanQRCodeActivity.class);
        mSharedPreferencesHelper.putInt(SCAN_REQUEST_CODE, 101);
        // 开始一个新的 Activity等候返回结果
        startActivityForResult(newIntent, 101);
    }

    private void getScanData(String mid) {

        showLoading();

        String methodName = "getMaterialDetailInfo";

        SoapUtil soapUtil = SoapUtil.getInstance(this);
        soapUtil.setDotNet(true);
        SoapParams params = new SoapParams();
        params.put("mid", mid);
        LogUtils.debugEInfo("mid=" + mid);

        /**
         * 请求
         */
        soapUtil.callEntry(getUrl(), BaseConstants.NAME_SPACE, methodName, params, new SoapListener() {
            @Override
            public void onSuccess(int statusCode, SoapObject object) {
                hideLoading();
                LogUtils.debugEInfo("onSuccess=" + mid);

                try {
                    String result = object.getProperty("getMaterialDetailInfoResult").toString();
                    LogUtils.debugEInfo("result=" + result);
                    if (result != null && !result.equals("[]") && !result.equals("anyType{}") && !result.equals("Error") && !result.equals("-100")) {
                        LogUtils.debugEInfo("result=" + result);

                        Gson gson = new Gson();
                        GetMaterialDetailInfo getMaterialDetailInfo = gson.fromJson(result, GetMaterialDetailInfo.class);

                        if (getMaterialDetailInfo != null) {

                            tvXiangMu.setText(getMaterialDetailInfo.getProjectName());
                            tvWuLiaoMingCheng.setText(getMaterialDetailInfo.getMaterial());
                            tvHeTongQianDingQiQi.setText(getMaterialDetailInfo.getContractDate());
                            tvPeiSongJiHuaRiQi.setText(getMaterialDetailInfo.getDistributionDate());
                            tvDaoHuoShiJian.setText(getMaterialDetailInfo.getArriveDate());
                            tvJiHuaShuLiang.setText(getMaterialDetailInfo.getSupplyPlanNum());
                            tvBenCiDaoHuoShuLiang.setText(getMaterialDetailInfo.getArriveNum());
                            tvKuCunShuLiang.setText(getMaterialDetailInfo.getInventoryNum());
                            tvGongYingShang.setText(getMaterialDetailInfo.getSupplier());
                            tvGongYingShangLianXiRen.setText(getMaterialDetailInfo.getSupplierPeople());
                            tvGongYingShangLianXiDianHua.setText(getMaterialDetailInfo.getSupplierPhone());
                            tvBeiZhu.setText(getMaterialDetailInfo.getRemark());
                            tvHuiShouBaoFeiZhuangTai.setText(getMaterialDetailInfo.getRecoverOrScrapState());
                            tvHuiShouBaoFeiShuLiang.setText(getMaterialDetailInfo.getRecoverOrScrapNum());
                            tvHuiShouBaoFeiXiangMu.setText(getMaterialDetailInfo.getRecoverOrScrapProject());
                            tvHuiShouBaoFeiCangKu.setText(getMaterialDetailInfo.getRecoverOrScrapStore());
//                            tvCangWeiWuLiaoShuLiang.setText(getMaterialDetailInfo.getInventorySumNum());
                            tvCangWeiWuLiaoShuLiang.setText(getMaterialDetailInfo.getArriveNum());
                            mTvDanWei.setText(getMaterialDetailInfo.getUnit());
                            //                        tvChuKuJiLu.setText(getMaterialDetailInfo.getOutStoreList());

                            if (getMaterialDetailInfo.getOutStoreList() != null && getMaterialDetailInfo.getOutStoreList().size() > 0) {
                                mOutStoreListBeans.clear();
                                mOutStoreListBeans.addAll(getMaterialDetailInfo.getOutStoreList());
                                mSaoMiaoChaKanXiangQingAdapter.notifyDataSetChanged();

                            }
                            if (getMaterialDetailInfo.getReturnStoreList() != null && getMaterialDetailInfo.getReturnStoreList().size() > 0) {
                                mReturnStoreListBeans.clear();
                                mReturnStoreListBeans.addAll(getMaterialDetailInfo.getReturnStoreList());
                                mSaoMiaoChaKanXiangQingAdapter_returnStoreList.notifyDataSetChanged();
                            }
                            if (getMaterialDetailInfo.getInStoreList() != null && getMaterialDetailInfo.getInStoreList().size() > 0) {
                                mInStoreListBeans.clear();
                                mInStoreListBeans.addAll(getMaterialDetailInfo.getInStoreList());
                                mSaoMiaoChaKanXiangQingAdapter_inStoreList.notifyDataSetChanged();
                            }
                            if (getMaterialDetailInfo.getInspectionList() != null && getMaterialDetailInfo.getInspectionList().size() > 0) {
                                mInspectionListBeans.clear();
                                mInspectionListBeans.addAll(getMaterialDetailInfo.getInspectionList());
                                mSaoMiaoChaKanXiangQingAdapter_inspectionList.notifyDataSetChanged();
                            }
                            if (getMaterialDetailInfo.getFirstCheckList() != null && getMaterialDetailInfo.getFirstCheckList().size() > 0) {
                                mFirstCheckListBeans.clear();
                                mFirstCheckListBeans.addAll(getMaterialDetailInfo.getFirstCheckList());
                                mSaoMiaoChaKanXiangQingAdapter_firstCheckList.notifyDataSetChanged();
                            }

                            if (getMaterialDetailInfo.getUppic() != null && getMaterialDetailInfo.getUppic().size() > 0) {
                                GlideUtil.loadImage(getContext(), getMaterialDetailInfo.getUppic().get(0), imgWuLiao);
                            }
                        }

                    } else {

                    }
                } catch (JsonSyntaxException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onFailure(int statusCode, String content, Throwable error) {
                hideLoading();
            }

            @Override
            public void onFailure(int statusCode, SoapFault fault) {
                hideLoading();
            }
        }, getAapiUserName(), getApiPwd());


    }

    @Override
    public void showLoading() {
        CProgressDialogUtils.showProgressDialog(this);
    }

    @Override
    public void hideLoading() {
        CProgressDialogUtils.cancelProgressDialog();
    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.makeText(this, message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerSaoMiaoChaKanXiangQingComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .saoMiaoChaKanXiangQingModule(new SaoMiaoChaKanXiangQingModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        mType = getIntent().getExtras().getString("type");
        if (mType.equals("2")) {
            return R.layout.activity_sao_miao_cha_kan_xiang_qing_2; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
        } else {
            return R.layout.activity_sao_miao_cha_kan_xiang_qing; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
        }
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        ToolbarUtils.initToolbarTitleBack(this, getString(R.string.activity_sao_miao_cha_kan_xiang_qing));
//        getSaoMiaoChaKanXiangQingData();

        mBtnRight.setImageDrawable(getResources().getDrawable(R.drawable.icon_scan));
        mBtnRight.setOnClickListener(mRightListener);

        initRecyclerView();
        initRecyclerView_ReturnStoreList();
        initRecyclerView_InStoreList();
        initRecyclerView_InspectionList();
        initRecyclerView_FirstCheckList();
    }

    private void initRecyclerView() {
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        mRecyclerView.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 0, getResources().getColor(R.color.public_client_line_color)));
        mSaoMiaoChaKanXiangQingAdapter = new SaoMiaoChaKanXiangQingAdapter(this, mOutStoreListBeans);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(linearLayoutManager);
        mRecyclerView.setAdapter(mSaoMiaoChaKanXiangQingAdapter);
    }

    private void initRecyclerView_ReturnStoreList() {
        mRecyclerViewReturnStoreList = (RecyclerView) findViewById(R.id.recyclerView_ReturnStoreList);
        mRecyclerViewReturnStoreList.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 0, getResources().getColor(R.color.public_client_line_color)));
        mSaoMiaoChaKanXiangQingAdapter_returnStoreList = new SaoMiaoChaKanXiangQingAdapter_ReturnStoreList(this, mReturnStoreListBeans);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerViewReturnStoreList.setLayoutManager(linearLayoutManager);
        mRecyclerViewReturnStoreList.setAdapter(mSaoMiaoChaKanXiangQingAdapter_returnStoreList);
    }

    private void initRecyclerView_InStoreList() {
        mRecyclerViewInStoreList = (RecyclerView) findViewById(R.id.recyclerView_InStoreList);
        mRecyclerViewInStoreList.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 0, getResources().getColor(R.color.public_client_line_color)));
        mSaoMiaoChaKanXiangQingAdapter_inStoreList = new SaoMiaoChaKanXiangQingAdapter_InStoreList(this, mInStoreListBeans);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerViewInStoreList.setLayoutManager(linearLayoutManager);
        mRecyclerViewInStoreList.setAdapter(mSaoMiaoChaKanXiangQingAdapter_inStoreList);
    }

    private void initRecyclerView_InspectionList() {
        mRecyclerViewInspectionList = (RecyclerView) findViewById(R.id.recyclerView_InspectionList);
        mRecyclerViewInspectionList.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 0, getResources().getColor(R.color.public_client_line_color)));
        mSaoMiaoChaKanXiangQingAdapter_inspectionList = new SaoMiaoChaKanXiangQingAdapter_InspectionList(this, mInspectionListBeans);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerViewInspectionList.setLayoutManager(linearLayoutManager);
        mRecyclerViewInspectionList.setAdapter(mSaoMiaoChaKanXiangQingAdapter_inspectionList);
    }

    private void initRecyclerView_FirstCheckList() {
        mRecyclerViewFirstCheckList = (RecyclerView) findViewById(R.id.recyclerView_FirstCheckList);
        mRecyclerViewFirstCheckList.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 0, getResources().getColor(R.color.public_client_line_color)));
        mSaoMiaoChaKanXiangQingAdapter_firstCheckList = new SaoMiaoChaKanXiangQingAdapter_FirstCheckList(this, mFirstCheckListBeans);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerViewFirstCheckList.setLayoutManager(linearLayoutManager);
        mRecyclerViewFirstCheckList.setAdapter(mSaoMiaoChaKanXiangQingAdapter_firstCheckList);
    }

    private void getSaoMiaoChaKanXiangQingData() {
        mPresenter.getSaoMiaoChaKanXiangQingData();
    }

    @Override
    public void getSaoMiaoChaKanXiangQingDataSuccess(SaoMiaoChaKanXiangQing entityData) {


    }


    @OnClick(R.id.btn_chu_ku)
    public void onViewClicked() {
        if (TextUtils.isEmpty(mid)) {
            showMessage("请先扫描物料二维码");
            return;
        }
        if (TextUtils.isEmpty(getEtChuKuShuLiang())) {
            showMessage("填写出库数量");
            return;
        }

        outStoreByScanMid(mid, getEtChuKuShuLiang());
    }

    @NotNull
    private String getEtChuKuShuLiang() {
        return etChuKuShuLiang.getText().toString().trim();
    }

    /**
     * @param
     * @return
     * @method
     * @description 扫描查看物料详情，填写数量，直接出库
     * @date: 2020/8/3 0003 9:16
     * @author: 小星
     */
    private void outStoreByScanMid(String mid, String outcount) {

        showLoading();

        String methodName = "OutStoreByScanMid";

        SoapUtil soapUtil = SoapUtil.getInstance(this);
        soapUtil.setDotNet(true);
        SoapParams params = new SoapParams();
        params.put("mid", mid);
        params.put("uid", mSharedPreferencesHelper.getString(BaseConstants.UID));
        params.put("remark", etBiaoShiXinXi.getText().toString().trim());
        params.put("outcount", outcount);

        /**
         * 请求
         */
        soapUtil.callEntry(getUrl(), BaseConstants.NAME_SPACE, methodName, params, new SoapListener() {
            @Override
            public void onSuccess(int statusCode, SoapObject object) {
                hideLoading();

                try {
                    String result = object.getProperty("OutStoreByScanMidResult").toString();
                    if (result != null && !result.equals("[]") && !result.equals("anyType{}") && !result.equals("Error") && !result.equals("-100")) {
                        showMessage(result);

                        if (result.equals("出库成功!")) {
                            getScanData(mid);
                        }
                    } else {

                    }
                } catch (JsonSyntaxException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onFailure(int statusCode, String content, Throwable error) {
                hideLoading();
            }

            @Override
            public void onFailure(int statusCode, SoapFault fault) {
                hideLoading();
            }
        }, getAapiUserName(), getApiPwd());


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
